package com.doit.spark.day02

import scala.io.{BufferedSource, Source}

/**
 * @DATE 2022/1/3/9:14
 * @Author MDK
 * @Version 2021.2.2
 * */
class ReadDataIterator extends Iterator[(String, String, String, Double)]{
  private val br: BufferedSource = Source.fromFile("data/a.txt")
  private val iterator: Iterator[String] = br.getLines()

  //赋值给hasNext方法
  override def hasNext: Boolean = iterator.hasNext
  override def next(): (String, String, String, Double) = {
    val line: String = iterator.next()
    val arr = line.split(",")
    (arr(0),arr(1),arr(2),arr(3).toDouble)
  }
}
